<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <!-- 微软的老式浏览器 -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <!-- 显示窗口 宽度 是 客户端的 屏幕 宽度 （就是 满屏 ！），显示的文字和图形的初始比例 是 1.0 -->
    <link rel="stylesheet" href="css/layui.mobile.css">
    <link rel="stylesheet" type="text/css" href="css/style.css"><!-- 基本样式 -->
    <link rel="stylesheet" type="text/css" href="css/about.css"><!-- 基本样式 -->
    <script src="js/common.js"></script>
    <title>匿名提问（对我提问）</title>
    <style>
        .m-user-messageCenter {
            padding: 10px 15px 1px 15px;
        }
        .unlock {
            margin-top: 5px;
        }
        .unlock h2 {
            font-size: 14px;
            font-weight: 500;
            color: #1b1b1b;
            line-height: 20px;
        }
        .system-messagesunlock{
            border-bottom: 1px solid #f4f4f4;
            padding-bottom: 5px;
        }
        *{
            box-sizing: content-box;
        }
        .dn{
            display: none;
        }
        .comments {
            position: relative;
            padding-bottom: 5px;
            margin-top: 10px;
        }
        .spinner{width:20px;height:20px;position:fixed;z-index:1002;top:50%;margin-top:-10px;left:50%;margin-left:-10px}.container1>div,.container2>div,.container3>div{width:6px;height:6px;background-color:#ff536a;border-radius:100%;position:absolute;-webkit-animation:bouncedelay 1.2s infinite ease-in-out;animation:bouncedelay 1.2s infinite ease-in-out;-webkit-animation-fill-mode:both;animation-fill-mode:both}.spinner .spinner-container{position:absolute;width:100%;height:100%}.container2{-webkit-transform:rotateZ(45deg);transform:rotateZ(45deg)}.container3{-webkit-transform:rotateZ(90deg);transform:rotateZ(90deg)}.circle1{top:0;left:0}.circle2{top:0;right:0}.circle3{right:0;bottom:0}.circle4{left:0;bottom:0}.container2 .circle1{-webkit-animation-delay:-1.1s;animation-delay:-1.1s}.container3 .circle1{-webkit-animation-delay:-1.0s;animation-delay:-1.0s}.container1 .circle2{-webkit-animation-delay:-0.9s;animation-delay:-0.9s}.container2 .circle2{-webkit-animation-delay:-0.8s;animation-delay:-0.8s}.container3 .circle2{-webkit-animation-delay:-0.7s;animation-delay:-0.7s}.container1 .circle3{-webkit-animation-delay:-0.6s;animation-delay:-0.6s}.container2 .circle3{-webkit-animation-delay:-0.5s;animation-delay:-0.5s}.container3 .circle3{-webkit-animation-delay:-0.4s;animation-delay:-0.4s}.container1 .circle4{-webkit-animation-delay:-0.3s;animation-delay:-0.3s}.container2 .circle4{-webkit-animation-delay:-0.2s;animation-delay:-0.2s}.container3 .circle4{-webkit-animation-delay:-0.1s;animation-delay:-0.1s}@-webkit-keyframes bouncedelay{0%,80%,100%{-webkit-transform:scale(0.0)}40%{-webkit-transform:scale(1.0)}}@keyframes bouncedelay{0%,80%,100%{transform:scale(0.0);-webkit-transform:scale(0.0)}40%{transform:scale(1.0);-webkit-transform:scale(1.0)}}#loading .mask{position:fixed;width:100%;background-color:#fff;top:0;left:0;height:100%;z-index:1001}
    </style>
</head>
<body >
<div id="loading">
    <div class="mask"></div>
    <div class="spinner">
        <div class="spinner-container container1">
            <div class="circle1"></div>
            <div class="circle2"></div>
            <div class="circle3"></div>
            <div class="circle4"></div>
        </div>
        <div class="spinner-container container2">
            <div class="circle1"></div>
            <div class="circle2"></div>
            <div class="circle3"></div>
            <div class="circle4"></div>
        </div>
        <div class="spinner-container container3">
            <div class="circle1"></div>
            <div class="circle2"></div>
            <div class="circle3"></div>
            <div class="circle4"></div>
        </div>
    </div>
</div>
    <!-- 头部导航 -s-->
    <div class="activitynav">
        <ul>
            <li style="border-right:1px solid #dedede;" class="activitynav-active" >
                <a href="questions-anonymously.html" id="questions-anonymously-btn">对我提问</a>
            </li>
            <li>
                <a href="Anonymous-comments.html" id="anonymous-comments-btn">我提问的</a>
            </li>
        </ul>
    </div>
    <!-- 头部导航-e-->

    <div id="list" style="padding-bottom: 60px">
        <!--<div class="m-user-messageCenter pr">-->
            <!--<div class="system-messagesunlock">-->
                <!--<img src="./cssimg/meimv.png">-->
                <!--<div class="unlock">-->
                    <!--<h2>您提出了问题您提出了问题您提出了问题您提出了问题您提出了问题</h2>-->
                    <!--<span>2017-06-11  9:00</span>-->
                <!--</div>-->
            <!--</div>-->
            <!--<p class="hdbtn">立即回答</p>-->
            <!--<p  class="hdbtn xghd dn">修改回答 ></p>-->
        <!--</div>-->
    </div>
<div class="nmts">暂时还没有对你发起匿名提问哦~</div>
<div class="commentsmain-w dn" id="box">
    <div>
        <img id="grtx">
        <input type="text" placeholder="在这里说点什么吧......" id="input" class="input">
        <input onclick="huida(this)" data-id="" type="button" value="发送" class="fsbtn2">
    </div>
</div>

<script src="js/jquery/jquery-2.2.4.min.js"></script>
<script src="js/utils.js"></script>
<script>
    var res = Utils.getRequestParam();
    Utils.historyBack(function () {
        if (typeof res['index'] != 'undefined') {
            window.location.href = res['index'] + '.html';
        } else {
            window.location.href = '/mine.html';
        }
    });
    console.log(res);
    if (typeof res['index'] != 'undefined') {
        var href = $("#questions-anonymously-btn").attr('href');
        $("#questions-anonymously-btn").attr('href', href + '?index=' + res['index']);

        var href = $("#anonymous-comments-btn").attr('href');
        $("#anonymous-comments-btn").attr('href', href + '?index=' + res['index']);
    }
    $("#grtx").attr("src",localStorage.txurl);
    $("body,html").css("height",$(window).height());
    var time=Date.parse(new Date())/1000;
    $.ajax({
        type : "GET",
        url : getRequestUrl("/user/get_question_self"),
        data:{
            timestamp:time,
            page_num:1,
            page_size:100
        },
        // contentType : "application/json",
        success : function(datas) {
            console.log(datas.response_params.total_cnt);
            if(datas.response_params.total_cnt>0){
                $(".nmts").hide();
            }
            var arr=datas.response_params.result;
            var strs="";
            $.each(arr,function (i,el){
                if(el.status=="1"){
                    strs+=`<div class="m-user-messageCenter pr"  data-id=`+el.question_id+`>
                          <div class="system-messagesunlock">
                              <img src="cssimg/logo_03.jpg">
                              <div class="unlock">
                                  <h2>`+el.question+`</h2>
                                  <span>`+gstime(el.insert_time)+`</span>
                              </div>
                          </div>
                            <div id="ly`+i+`">
                            </div>
                                <p class="hdbtn"  data-id=`+el.question_id+` data-index="ly`+i+`" onclick="showhd(this)">立即回答</p>
                                <p  class="hdbtn xghd dn" data-id=`+el.question_id+` data-index="ly`+i+`" onclick="showhd(this)">修改回答 ></p>
                    </div>`
                }
                else {
                    strs+=`<div class="m-user-messageCenter pr"  data-id=`+el.question_id+`>
                          <div class="system-messagesunlock">
                              <img src="cssimg/logo_03.jpg">
                              <div class="unlock">
                                  <h2>`+el.question+`</h2>
                                  <span>`+gstime(el.insert_time)+`</span>
                              </div>

                          </div>
                            <div id="ly`+i+`">
                                   <div class="comments">
                        <img src=`+localStorage.txurl+`>
                        <p>`+el.answer+`</p>
                        <span>`+gstime(el.update_time)+` </span>
                        </div>
                            </div>
                                <p  class="hdbtn xghd" data-id=`+el.question_id+` data-index="ly`+i+`" onclick="showhd(this)">修改回答 ></p>
                    </div>`
                }

            });
            $(strs).appendTo("#list");
            $("#loading").hide();
        },
        error : function(err) {
        	dealCPErrorResponse(err);
        }
    });
    function showhd(obj) {
        var $this=$(obj);
        var id=$this.attr("data-id");
        var index=$this.attr("data-index");
        $("#box").show();
        $(".fsbtn2").attr("data-id",id);
        $(".fsbtn2").attr("data-index",index)
    }
    function huida(obj) {
        var $this=$(obj);
        var id=$this.attr("data-id");
        var index="#"+$this.attr("data-index");
        //var str
        if($("#input").val()==""){
            return false
        }
        var timev=new Date().getTime()/1000;
        $.ajax({
            type : "POST",
            url : getRequestUrl("/user/answer_question"),
            data:{
                question_id:id,
                answer:$("#input").val()
            },
            // contentType : "application/json",
            success : function(datas) {
                console.log(datas.response_params.result);
                if(datas.response_params.result=="0"){
                    var sts=`<div class="comments">
                                    <img src=`+localStorage.txurl+`>
                                    <p>`+$("#input").val()+`</p>
                                    <span>`+gstime(timev)+` </span>
                                </div> `;
                    $("#input").val("");
                    $(index).html("");
                    $("#box").hide();
                    $(sts).appendTo(index)
                }
            },
            error : function(err) {
            	dealCPErrorResponse(err);
            }
        });

    }
    function gstime(time) {
        var date = new Date(time*1000);
        Y = date.getFullYear() + '-';
        M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
        D = date.getDate() + ' ';
        h = date.getHours()<10 ? '0' + date.getHours()+':' : date.getHours()+':';
        m = date.getMinutes()<10? '0'+date.getMinutes():date.getMinutes();
        //s = date.getSeconds();
        //console.log(Y+M+D+h+m);
        return Y+M+D+h+m
    }
</script>
</body>
</html>